package com.example.bootrabbitmq.direct;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.core.ReturnedMessage;
import org.springframework.amqp.rabbit.connection.CorrelationData;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.UUID;

@Component
@Slf4j
public class DirectRabbitProducer {

    //
    @Autowired
    private RabbitTemplate rabbitTemplate;



//    @Override
//    public void confirm(CorrelationData correlationData, boolean ack, String cause) {
//        log.warn("ack发送确认");
//        log.warn("correlationData消息唯一标识：" + correlationData);
//        log.warn("ack确认结果：" + ack);
//        log.warn("cause失败原因：" + cause);
//    }
//————————————————
//    版权声明：本文为CSDN博主「隔壁老瓦」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
//    原文链接：https://blog.csdn.net/wxb880114/article/details/105836274/


    public void sendMsg(String content) {
        CorrelationData correlationId = new CorrelationData(UUID.randomUUID().toString());
        //把消息放入ROUTINGKEY_A对应的队列当中去，对应的是队列A
        rabbitTemplate.convertAndSend("my-direct-exchange_A",
                "spring-boot-routingKey-A",
                content, correlationId);
    }


}
